package io.github.maojian.str;

import org.junit.Test;

/**
 * @Auther: jian.mao
 * @Date: 2022-06-21 09:53
 * @Description: https://leetcode.cn/problems/defanging-an-ip-address/
 */
public class Q1108 {
    public String defangIPaddr(String address) {
        String rst = address.replace(".", "[.]");
        String result = address.replaceAll("\\.", "[.]");
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < address.length(); i++) {
            if (address.charAt(i) == '.'){
                stringBuilder.append("[.]");
            }else {
                stringBuilder.append(address.charAt(i));
            }
        }
        return stringBuilder.toString();
    }

    @Test
    public void test() {
        String address = "1.1.1.1";
        System.out.println(defangIPaddr(address));
    }
}
